//
//  ShotObject.m
//  Agility
//
//  Created by Dominique d'Argent on 17.03.11.
//  Copyright 2011 Nicky Nubbel. All rights reserved.
//

#import "HomingShotObject.h"

@implementation HomingShotObject

+ (NSString *)imageName {
    return @"homingShot";
}

- (id)initWithPosition:(CGPoint)newPosition target:(GameObject *)newTarget trajectory:(CGFloat)newTrajectory {
    self = [super initWithPosition:newPosition target:newTarget trajectory:newTrajectory];
    
    if (self) {
        maxLifeTime *= 1.5;
    }
    
    return self;
}

- (void)updatePositionWithTimeInterval:(NSTimeInterval)timeInterval {
    if (!CGPointEqualToPoint(target.position, destination)) {
        destination = target.position;
        
        trajectory = [self angleToPoint:destination];
    }
    
    [super updatePositionWithTimeInterval:timeInterval];
}

@end
